package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.MessageBean;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.bean.UserSettingBean;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.LoginService;
import com.appwoo.txtws.wheel.widget.NumericWheelAdapter;
import com.appwoo.txtws.wheel.widget.OnWheelChangedListener;
import com.appwoo.txtws.wheel.widget.OnWheelScrollListener;
import com.appwoo.txtws.wheel.widget.WheelView;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import org.xmlpull.v1.XmlPullParserException;

public class MoreSetActivity extends AppActivity
{
  protected String age = "1319";
  private String alertString = "";
  protected int brewTimeH = 0;
  protected int brewTimeM = 0;
  private Button btnSave;
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  private String equipName = "";
  private RadioButton high;
  private TextView highlow_text;
  private int hour;
  private WheelView hours;
  private LinearLayout layout_Location;
  private String level = "1";
  private String loctime;
  private LoginService loginService = null;
  private String logswitch;
  private RadioButton low;
  private MessageBean messageBean = null;
  private int min;
  private WheelView mins;
  private RadioButton rbAge1;
  private RadioButton rbAge2;
  private CheckBox rbElec;
  private RqSP rqsp;
  private RadioButton set_close;
  private RadioButton set_open;
  private RadioButton set_time1;
  private RadioButton set_time2;
  private RadioButton set_time3;
  private RadioButton set_time4;
  protected String sleepset = "0";
  private boolean timeChanged = false;
  private TextView timeNotify;
  private boolean timeScrolled = false;
  private ProgressDialog v_progressDialog = null;

  private void ShowTimer(String paramString)
  {
    if (!"0".equals(paramString))
      alertMessage(getString(2131427674));
  }

  private void addChangingListener(WheelView paramWheelView, final String paramString)
  {
    paramWheelView.addChangingListener(new OnWheelChangedListener()
    {
      public void onChanged(WheelView paramAnonymousWheelView, int paramAnonymousInt1, int paramAnonymousInt2)
      {
        if (paramAnonymousInt2 != 1);
        for (String str = paramString + " "; ; str = paramString)
        {
          paramAnonymousWheelView.setLabel(str);
          return;
        }
      }
    });
  }

  private void addListener()
  {
    this.high.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        MoreSetActivity.this.highlow_text.setText(2131427486);
      }
    });
    this.low.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        MoreSetActivity.this.highlow_text.setText(2131427485);
      }
    });
    this.btnSave.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        MoreSetActivity.this.setBrewHourTime(Integer.valueOf(MoreSetActivity.this.hour));
        MoreSetActivity.this.setBrewMinTime(Integer.valueOf(MoreSetActivity.this.min));
        if ((MoreSetActivity.this.brewTimeH == 0) && (MoreSetActivity.this.brewTimeM == 0))
        {
          MoreSetActivity.this.alertMessage(MoreSetActivity.this.getString(2131427903));
          return;
        }
        if ((MoreSetActivity.this.brewTimeH == 0) && (MoreSetActivity.this.brewTimeM < 1))
        {
          MoreSetActivity.this.alertMessage(MoreSetActivity.this.getString(2131427904));
          return;
        }
        if (MoreSetActivity.this.rbAge1.isChecked())
          MoreSetActivity.this.age = "312";
        if (MoreSetActivity.this.rbElec.isChecked())
          MoreSetActivity.this.sleepset = "1";
        if (MoreSetActivity.this.high.isChecked())
          MoreSetActivity.this.level = "1";
        if (MoreSetActivity.this.low.isChecked())
          MoreSetActivity.this.level = "0";
        if (MoreSetActivity.this.set_open.isChecked())
          MoreSetActivity.this.logswitch = "1";
        if (MoreSetActivity.this.set_close.isChecked())
          MoreSetActivity.this.logswitch = "0";
        if (MoreSetActivity.this.set_time1.isChecked())
          MoreSetActivity.this.loctime = "15";
        if (MoreSetActivity.this.set_time2.isChecked())
          MoreSetActivity.this.loctime = "30";
        if (MoreSetActivity.this.set_time3.isChecked())
          MoreSetActivity.this.loctime = "45";
        if (MoreSetActivity.this.set_time4.isChecked())
          MoreSetActivity.this.loctime = "60";
        new MoreSetActivity.SettingsAsyncTask(MoreSetActivity.this).execute(new String[] { "rqSubmitSet" });
      }
    });
  }

  private String bgRQUserSetting(String paramString)
  {
    while (true)
    {
      List localList;
      int i;
      try
      {
        localList = this.loginService.RQUserSetting(this.rqsp.getLgDevAccount(this), this.rqsp.getLgDevId(this), paramString, this);
        str = "";
        i = 0;
        if (i >= localList.size())
          return str;
      }
      catch (IOException localIOException)
      {
        this.alertString = getString(2131427524);
        return null;
      }
      catch (XmlPullParserException localXmlPullParserException)
      {
        this.alertString = getString(2131427524);
        return null;
      }
      catch (TimeOutException localTimeOutException)
      {
        this.alertString = getString(2131427526);
        return null;
      }
      catch (NotFoundNetWorkException localNotFoundNetWorkException)
      {
        this.alertString = getString(2131427525);
        return null;
      }
      String str = str + ((UserSettingBean)localList.get(i)).getParaName() + "=" + ((UserSettingBean)localList.get(i)).getParaVal() + "@";
      i++;
    }
  }

  private String bgUserSetting(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6)
  {
    if (this.equipName != null);
    try
    {
      StateBean localStateBean = this.loginService.UDUserSettingAll(this.rqsp.getLgDevAccount(this), this.rqsp.getLgDevId(this), paramString1, paramString2, paramString3, paramString4, "1", paramString5, paramString6, this);
      if (!localStateBean.getCode().equals("0"));
      for (this.alertString = localStateBean.getDesc(); ; this.alertString = getString(2131427527))
        return this.alertString;
    }
    catch (IOException localIOException)
    {
      while (true)
        localIOException.printStackTrace();
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
        localXmlPullParserException.printStackTrace();
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
        localTimeOutException.printStackTrace();
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
        localNotFoundNetWorkException.printStackTrace();
    }
  }

  private String convertNum(Integer paramInteger)
  {
    String str = String.valueOf(paramInteger);
    if (str.length() == 1)
      str = "0" + str;
    return str;
  }

  private void createOrShowDialog()
  {
    if ((this.v_progressDialog == null) || (!this.v_progressDialog.isShowing()))
    {
      this.v_progressDialog = new ProgressDialog(this);
      this.v_progressDialog.setMessage(getString(2131427516));
      this.v_progressDialog.setCancelable(true);
      this.v_progressDialog.show();
    }
  }

  private String gettime()
  {
    int i = Integer.valueOf(this.brewTimeH).intValue();
    return String.valueOf(60 * (Integer.valueOf(this.brewTimeM).intValue() + i * 60) / 30);
  }

  private void initActionBar()
  {
    hideBarHome();
    setBarTitle(getResources().getString(2131427348));
    setBarBackOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        MoreSetActivity.this.finish();
      }
    });
  }

  private void initView()
  {
    this.timeNotify = ((TextView)findViewById(2131493288));
    this.btnSave = ((Button)findViewById(2131493302));
    this.rbAge1 = ((RadioButton)findViewById(2131493289));
    this.rbAge2 = ((RadioButton)findViewById(2131493290));
    this.set_open = ((RadioButton)findViewById(2131493299));
    this.set_close = ((RadioButton)findViewById(2131493300));
    this.rbElec = ((CheckBox)findViewById(2131493296));
    this.high = ((RadioButton)findViewById(2131493297));
    this.low = ((RadioButton)findViewById(2131493298));
    this.layout_Location = ((LinearLayout)findViewById(2131493291));
    RqSP localRqSP = new RqSP();
    if ((localRqSP.getExitVal(this) == 0) && (Global.isBinded == 1))
      if (localRqSP.getUserFrom(this).equalsIgnoreCase("GDDX"))
        this.layout_Location.setVisibility(8);
    while (true)
    {
      this.set_time1 = ((RadioButton)findViewById(2131493292));
      this.set_time2 = ((RadioButton)findViewById(2131493293));
      this.set_time3 = ((RadioButton)findViewById(2131493294));
      this.set_time4 = ((RadioButton)findViewById(2131493295));
      this.highlow_text = ((TextView)findViewById(2131493301));
      this.rqsp = new RqSP();
      this.equipName = this.rqsp.getLgDevId(this);
      this.loginService = new LoginService();
      this.high.setChecked(true);
      this.highlow_text.setText(2131427486);
      this.set_open.setOnClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          MoreSetActivity.this.alertMessage(MoreSetActivity.this.getResources().getString(2131428121));
        }
      });
      return;
      if (LoginActivity.USERFROM.equals("GDDX"))
        this.layout_Location.setVisibility(8);
    }
  }

  private void postRQSet(String paramString)
  {
    String[] arrayOfString1 = paramString.split("@");
    int i = arrayOfString1.length;
    int j = 0;
    if (j >= i)
      return;
    String str = arrayOfString1[j];
    String[] arrayOfString2;
    if (!"".equals(str))
    {
      arrayOfString2 = str.split("=");
      if (!arrayOfString2[0].equalsIgnoreCase("synctime"))
        break label74;
      setWheelValue(arrayOfString2[1]);
    }
    while (true)
    {
      j++;
      break;
      label74: if (arrayOfString2[0].equalsIgnoreCase("sleepset"))
      {
        if (arrayOfString2[1] == null)
          arrayOfString2[1] = "1";
        if (arrayOfString2[1].equals("1"))
          this.rbElec.setChecked(true);
        else
          this.rbElec.setChecked(false);
      }
      else if (arrayOfString2[0].equalsIgnoreCase("agegroup"))
      {
        if (arrayOfString2[1] == null)
          arrayOfString2[1] = "312";
        if (arrayOfString2[1].equals("312"))
          this.rbAge1.setChecked(true);
        else
          this.rbAge2.setChecked(true);
      }
      else if (arrayOfString2[0].equalsIgnoreCase("managelevel"))
      {
        if (arrayOfString2[1] == null)
          arrayOfString2[1] = "0";
        if (arrayOfString2[1].equals("0"))
          this.low.setChecked(true);
        else
          this.high.setChecked(true);
      }
      else if (arrayOfString2[0].equalsIgnoreCase("logswitch"))
      {
        if (arrayOfString2[1] == null)
          arrayOfString2[1] = "0";
        if (arrayOfString2[1].equals("1"))
          this.set_open.setChecked(true);
        else
          this.set_close.setChecked(true);
      }
      else if (arrayOfString2[0].equalsIgnoreCase("loctime"))
      {
        if (arrayOfString2[1] == null)
          arrayOfString2[1] = "30";
        if (arrayOfString2[1].equals("15"))
          this.set_time1.setChecked(true);
        else if (arrayOfString2[1].equals("30"))
          this.set_time2.setChecked(true);
        else if (arrayOfString2[1].equals("45"))
          this.set_time3.setChecked(true);
        else if (arrayOfString2[1].equals("60"))
          this.set_time4.setChecked(true);
      }
    }
  }

  private void postUdCtrl(String paramString)
  {
    if (!"".equals(paramString))
    {
      alertMessage(this.alertString);
      return;
    }
    alertMessage(getString(2131428051));
  }

  private void setBrewHourTime(Integer paramInteger)
  {
    this.brewTimeH = paramInteger.intValue();
  }

  private void setBrewMinTime(Integer paramInteger)
  {
    this.brewTimeM = paramInteger.intValue();
  }

  private void setWheel()
  {
    this.hours = ((WheelView)findViewById(2131493286));
    this.hours.setAdapter(new NumericWheelAdapter(0, 23));
    this.hours.setLabel(getString(2131427912));
    this.hours.setCyclic(true);
    this.mins = ((WheelView)findViewById(2131493287));
    this.mins.setAdapter(new NumericWheelAdapter(0, 59, "%02d"));
    this.mins.setLabel(getString(2131427913));
    this.mins.setCyclic(true);
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.get(11);
    localCalendar.get(12);
    this.hours.setCurrentItem(1);
    this.mins.setCurrentItem(0);
    this.hour = 1;
    this.min = 0;
    this.timeNotify.setText(getString(2131427917) + convertNum(Integer.valueOf(this.hour)) + getString(2131427912) + convertNum(Integer.valueOf(this.min)) + getString(2131427913));
    addChangingListener(this.mins, getString(2131427913));
    addChangingListener(this.hours, getString(2131427912));
    OnWheelChangedListener local3 = new OnWheelChangedListener()
    {
      public void onChanged(WheelView paramAnonymousWheelView, int paramAnonymousInt1, int paramAnonymousInt2)
      {
        if (!MoreSetActivity.this.timeScrolled)
        {
          MoreSetActivity.this.timeChanged = true;
          MoreSetActivity.this.hour = MoreSetActivity.this.hours.getCurrentItem();
          MoreSetActivity.this.min = MoreSetActivity.this.mins.getCurrentItem();
          MoreSetActivity.this.timeNotify.setText(MoreSetActivity.this.getString(2131427917) + MoreSetActivity.this.convertNum(Integer.valueOf(MoreSetActivity.this.hour)) + MoreSetActivity.this.getString(2131427912) + MoreSetActivity.this.convertNum(Integer.valueOf(MoreSetActivity.this.min)) + MoreSetActivity.this.getString(2131427913));
          MoreSetActivity.this.timeChanged = false;
        }
      }
    };
    this.hours.addChangingListener(local3);
    this.mins.addChangingListener(local3);
    OnWheelScrollListener local4 = new OnWheelScrollListener()
    {
      public void onScrollingFinished(WheelView paramAnonymousWheelView)
      {
        MoreSetActivity.this.timeScrolled = false;
        MoreSetActivity.this.timeChanged = true;
        MoreSetActivity.this.hour = MoreSetActivity.this.hours.getCurrentItem();
        MoreSetActivity.this.min = MoreSetActivity.this.mins.getCurrentItem();
        MoreSetActivity.this.timeNotify.setText(MoreSetActivity.this.getString(2131427917) + MoreSetActivity.this.convertNum(Integer.valueOf(MoreSetActivity.this.hour)) + MoreSetActivity.this.getString(2131427912) + MoreSetActivity.this.convertNum(Integer.valueOf(MoreSetActivity.this.min)) + MoreSetActivity.this.getString(2131427913));
        MoreSetActivity.this.timeChanged = false;
      }

      public void onScrollingStarted(WheelView paramAnonymousWheelView)
      {
        MoreSetActivity.this.timeScrolled = true;
      }
    };
    this.hours.addScrollingListener(local4);
    this.mins.addScrollingListener(local4);
  }

  private void setWheelValue(String paramString)
  {
    try
    {
      int i = 30 * Integer.valueOf(paramString).intValue();
      int j = i / 3600;
      int k = (i - 60 * (j * 60)) / 60;
      this.hours.setCurrentItem(j);
      this.mins.setCurrentItem(k);
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  protected void backKeyCallBack()
  {
    finish();
  }

  public void onBackPressed()
  {
    finish();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903155);
    initActionBar();
    initView();
    setWheel();
    addListener();
    new SettingsAsyncTask().execute(new String[] { "rqSet" });
  }

  public class SettingsAsyncTask extends AsyncTask<String, Integer, String>
  {
    private String method = "";

    public SettingsAsyncTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.method = paramArrayOfString[0];
      if (this.method.equals("rqSet"))
        return MoreSetActivity.this.bgRQUserSetting("SyncTime,SleepSet,AgeGroup,ManageLevel,LogSwitch,LocTime");
      if (this.method.equalsIgnoreCase("rqSubmitSet"))
        return MoreSetActivity.this.bgUserSetting(MoreSetActivity.access$1(MoreSetActivity.this), MoreSetActivity.this.age, MoreSetActivity.this.sleepset, MoreSetActivity.this.level, MoreSetActivity.this.logswitch, MoreSetActivity.this.loctime);
      return "";
    }

    protected void onPostExecute(String paramString)
    {
      if (this.method.equals("rqSet"))
        if ((paramString == null) || (paramString.equals("")))
          MoreSetActivity.this.alertMessage(MoreSetActivity.this.alertString);
      while (true)
      {
        MoreSetActivity.this.v_progressDialog.dismiss();
        return;
        MoreSetActivity.this.postRQSet(paramString);
        continue;
        if (this.method.equals("rqSubmitSet"))
          MoreSetActivity.this.postUdCtrl(paramString);
      }
    }

    protected void onPreExecute()
    {
      MoreSetActivity.this.createOrShowDialog();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.MoreSetActivity
 * JD-Core Version:    0.6.2
 */